<?php
/***************************\
File :    
Created:  
Update:   
Author:   Eugene Heriniaina
Email:    hery@serasera.org
Function: 
Comment:  

\***************************/


		switch ($task) { 
			case 'remove':
			case 'delete':
				profile_delete( $option, strval( $cid[0] ) );
				break;
			case 'orderup':
				profile_order(  strval( $cid[0] ), $c_id, -1, $option );
				break;
			case 'orderdown':
				profile_order(  strval( $cid[0] ), $c_id, 1, $option );
				break;
			case "search":
				profile_search_form( $option );
				break;
			case "save":

				profile_save( $option );
				break;
			case "new":
			case "edit":
				profile_edit( $option, strval($cid[0]) , $c_id );
				break;
			default:
				profile_list( $option, $c_id );
				break;
		}


/**
* Moves the order of a record
* @param integer The increment to reorder by
*/
function profile_order( $username, $c_id, $inc, $option ) {
	global $database, $option, $rub, $Itemid;

	$row = new congregationMember( $database );
	
	$row->load( $username );
	$row->move( $inc, "c_id = $c_id" );

	mosRedirect( ("?option=$option&rub=$rub&c_id=$c_id") );
}

function profile_delete( $option, $username ) {
	global $database, $access;

	$row = new congregationMember( $database );
	$row->load( $username );
	
	$query = "DELETE FROM #__congregation_profile"
	. "\n WHERE username = '$username' "
	;
	$database->setQuery( $query );
	if (!$database->query()) {
		echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
	}
	$row->updateOrder("c_id='$row->c_id'");

	mosRedirect("?option=$option&rub=profile&c_id=$row->c_id");
}


//manage members
function profile_search_form( $option ) {
	global $database, $my;
	if(!$my->username) {
		mosNotAuth();
		return;
	}

	//load used countries
	$query  = "SELECT nationality FROM #__congregation_profile GROUP BY nationality ORDER BY nationality"; 
	$database->setQuery( $query );
	$nations = $database->loadObjectList();

	//load languages 
	$languages=null;
	$database->setQuery( "SELECT l.*"
		. "\nFROM #__languages AS l"
		. "\nORDER BY l.active desc, l.ordering, l.name"
	);
	$languages = $database->loadObjectList();

	HTML_congregation::profile_search_form( $nations, $languages, $option );
}

function profile_show( $option, $username ) {
	global $database, $my;
	if(!$my->username) {
		mosNotAuth();
		return;
	}
	
	/*
	$row = new congregationMember( $database );
	$row->load( $username );

	if(!$row->username) {
		echo "<script> alert('". _Profile_Not_Found ."'); window.history.go(-1); </script>n";
		exit();
	}
	*/

	$query = "SELECT p.*, u.email, l.name as language, c.* , s.abbr as status_abbr, s.text as status_text "
	. "\nFROM #__congregation_profile AS p "
	. "\nLEFT JOIN #__users AS u ON p.username=u.username "
	. "\nLEFT JOIN #__languages AS l ON p.language=l.iso "
	. "\nLEFT JOIN #__congregation_status AS s ON p.status=s.id "
	. "\nLEFT JOIN #__congregation_casa AS c ON p.c_id=c.c_id "
	. "\nWHERE p.username='$username'"
	;
	
	$database->setQuery( $query );
	$row =  $database->loadObjectList();

	HTML_congregation::profile_show( $row[0], $option );
}
function profile_list( $option, $c_id = "" ) {
	global $database;

	$nationality	= trim( mosGetParam( $_REQUEST, 'nationality'	,	""		) );
	$language		= trim( mosGetParam( $_REQUEST, 'language'		,	""		) );
	$picfile		= trim( mosGetParam( $_REQUEST, 'picfile'		,	""		) );
	$txtsearch		= trim( mosGetParam( $_REQUEST, 'txtsearch'		,	""		) );
	

//for listing
	$limit 		= intval( mosGetParam( $_REQUEST, 'limit', 20 ) );
	$limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) );


	$where = array();

	if($c_id) {
		$where[] = " p.c_id='$c_id' ";
	}

    if($nationality) {
    	$where[] = " p.nationality='$nationality' ";
    }
    if($language) {
    	$where[] = " p.language='$language' ";
    }
    if($picfile) {
    	$where[] = " p.picfile<>'' ";
   }

    if($txtsearch) {
		$tmp = " (p.lname LIKE '%". ereg_replace(" ", "%' OR p.lname LIKE '%", $txtsearch). "%' ";
		$tmp .= " OR p.fname LIKE '%". ereg_replace(" ", "%' OR p.fname LIKE '%", $txtsearch). "%' ";
		$tmp .= " OR u.username LIKE '%". ereg_replace(" ", "%' OR u.username LIKE '%", $txtsearch). "%') ";
    	$where[] = $tmp;
   }

	$query = "SELECT count(*) FROM #__users AS u, #__congregation_profile AS p " 
	. "\nWHERE u.username=p.username  "
	. (count( $where ) ? "\n AND " . implode( ' AND ', $where ) : "")
	;


	$database->setQuery( $query );
	$total = $database->loadResult();
	
	if ( $total <= $limit ) $limitstart = 0;

	require_once( $GLOBALS['mosConfig_absolute_path'] . '/administrator/includes/pageNavigation.php' );

	$pageNav = new mosPageNav( $total, $limitstart, $limit  );

	$query = "SELECT u.username as lusername, u.email as lemail, p.* "
	. "\nFROM #__users AS u, #__congregation_profile AS p "
	. "\nWHERE u.username=p.username "
	. (count( $where ) ? "\n AND " . implode( ' AND ', $where ) : "")
	. "\nORDER BY ordering, lname DESC"
	. "\nLIMIT ".$pageNav->limitstart.",".$pageNav->limit
	;

	$database->setQuery( $query );
	$rows = $database->loadObjectList();


	HTML_profile::profile_list( $rows, $option , $pageNav);

}

function profile_save( $option ) {
  global $database, $my, $mosConfig_absolute_path, $mosConfig_live_site;

	$b_year = mosGetParam( $_REQUEST, 'b_year', array() ) ;
	$b_month = mosGetParam( $_REQUEST, 'b_month', array());
	$b_day = mosGetParam( $_REQUEST, 'b_day', array() ) ;
	$b_place = mosGetParam( $_REQUEST, 'b_place', array() );
	$removepic = mosGetParam( $_REQUEST, 'removepic', '0');

	$row = new congregationMember( $database );

	if (!$row->bind( $_POST )) {
		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>n";
		exit();
	}


	//check if username has already profile then update
	//otherwise create a new one

	$query = "SELECT username FROM #__congregation_profile WHERE username='$row->username'";

	$database->setQuery( $query );

	if($row->username != $database->loadResult()) {
		$query = "INSERT INTO #__congregation_profile (username) VALUES ('$row->username')";
		$database->setQuery($query);
		$database->query();
	}

	if($removepic == '1') {
		$row->picfile = "";
	}

	$row->bdate = $b_year[0]."-".$b_month[0]."-".$b_day[0];
	$row->bplace = $b_place[0];
	$row->edate = $b_year[1]."-".$b_month[1]."-".$b_day[1];
	$row->eplace = $b_place[1];
	$row->ndate = $b_year[2]."-".$b_month[2]."-".$b_day[2];
	$row->nplace = $b_place[2];
	$row->vdate = $b_year[3]."-".$b_month[3]."-".$b_day[3];
	$row->vplace = $b_place[3];
	$row->fdate = $b_year[4]."-".$b_month[4]."-".$b_day[4];
	$row->fplace = $b_place[4];
	$row->odate = $b_year[5]."-".$b_month[5]."-".$b_day[5];
	$row->oplace = $b_place[5];
	$row->ddate = $b_year[6]."-".$b_month[6]."-".$b_day[6];
	$row->dplace = $b_place[6];

	if (!$row->check()) {
		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
		exit();
	}


///// sary insertion
$imagefile_name = $_FILES['imagefile']['tmp_name'];
$imagefile = $_FILES['imagefile']['name'];

if (@is_uploaded_file($imagefile_name)) {

	if (!eregi("(\.jpg|\.jpeg|\.png|\.gif)$", $imagefile)){
		$errmsg .= "<li> ". _Congregation_Image_Error . " " . $imagefile ."</li>";
	} else {
		// photodir
			// photodir
			if(is_dir($mosConfig_absolute_path . "/media/profiles")) {
				$photodir = $mosConfig_absolute_path . "/media/profiles/";
				$photohtml = $mosConfig_live_site . "/media/profiles/";
			} elseif(mkdir($mosConfig_absolute_path . "/media/profiles")) {
				$photodir = $mosConfig_absolute_path . "/media/profiles/";
				$photohtml = $mosConfig_live_site . "/media/profiles/";
			} else {
				$photodir = $mosConfig_absolute_path . "/media/";
				$photohtml = $mosConfig_live_site . "/media/";
			}



				/*
				verifier-na raha azo reduiser-na
				sinon apetraka fotsiny
				*/
				var_dump($photodir . $imagefile);
					if(move_uploaded_file($imagefile_name, $photodir . "b" . $imagefile)) {
						$size = GetImageSize($photodir . "b" . $imagefile);
						$imagewidth = $size[0];
						$imageheight = $size[1];
						$imagetype = $size[2];
						
						if($imagewidth > 100) {
							$new_w = 100;
							$ratio = ($imagewidth / $new_w);

							$new_h = round($imageheight / $ratio);
							$pic_thumb = 1;

							if ($imagetype=="2") {
							$src_img = imagecreatefromjpeg($photodir . "b" . $imagefile);
							$dst_img = ImageCreateTrueColor($new_w,$new_h);
							imagecopyresized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img), imagesy($src_img));
							imagejpeg($dst_img, $photodir . "s".$imagefile);
							} elseif  ($imagetype=="3") {
							$src_img=ImageCreateFrompng($photodir . "b" . $imagefile);
							$dst_img=ImageCreateTrueColor($new_w,$new_h);
							ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img), ImageSY($src_img));
							Imagepng($dst_img, $photodir . "s".$imagefile);
							}
							
						}
						$new_w = $imagewidth;
						$new_h = $imageheight;
						$pic_thumb = 1;

						//unlink($photodir . $saryfile);
						
						$row->picfile = $imagefile;
					} else {
						$errmsg .= "<li> ".$str[pic_error]."</li>";
					}
	}
	}
///// sary insertion end



	/*
	if (!$row->check()) {
		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
		exit();
	}
	*/

	if (!$row->store()) {
		$row->getError();
		var_dump($row);
		exit;
		echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>n";
		exit();
	}
	$row->updateOrder("c_id='$row->c_id'");

	mosRedirect("?option=$option&rub=profile&c_id=$row->c_id");

}


function profile_edit( $option, $username ) {
	global $database, $c_id;

	$row = new congregationMember( $database );
	$row->load( $username );

	$lists = array();
	//load languages 

	$database->setQuery( "SELECT l.*"
		. "\nFROM #__languages AS l "
		. "\nORDER BY l.active desc, l.ordering, l.name"
	);
	$lists['language'] = $database->loadObjectList();
	

	//load new users (no profile yet) 

	$database->setQuery( "SELECT u.username "
		. "\nFROM #__users AS u "
		. (!$row->username ? "\nLEFT JOIN #__congregation_profile AS p ON u.username=p.username "
		. "\nWHERE p.username IS NULL " : "")
		. "\nORDER BY u.username "
	);
	$lists['users'] = $database->loadObjectList();
	


	//load houses  
	$database->setQuery( "SELECT * FROM #__congregation_casa ORDER BY p_id, c_city");

	$lists['casa'] = $database->loadObjectList();

	//load status  
	$database->setQuery( "SELECT * FROM #__congregation_status ORDER BY ordering");

	$lists['status'] = $database->loadObjectList();


  HTML_profile::profile_edit( $row, $option, $lists);
}

class HTML_profile {


	function profile_list( $rows, $option , &$pageNav){
		global $params, $Itemid, $c_id;
			?>
		<table class="adminheading">
		<tr>
			<th>
			<?php echo _Profile_List; ?>
			</th>
		</tr>
		</table>
		<form action="index2.php" method="get">
		<table border="0" width="100%">
			<tr valign="top">
				<td align="right">
				<?php echo _Profile_Search ?>
				<input type='text' name='txtsearch' size=30 />
				<input type='submit' name='bouton' value="   <?php echo _Profile_Search_Button ;?>   " />
				<input type="hidden" name="option" value="<?php echo $option ;?>" />
				<input type="hidden" name="rub" value="profile" />
				<input type="hidden" name="c_id" value="<?php echo $c_id ;?>" />
				<input type="hidden" name="task" value="list" /><br>
				<a href="<?php echo ("index.php?option=$option&rub=member&task=search&Itemid=$Itemid") ;?>"><?php echo _Profile_Advanced_Search ;?></a>
		</table>
		</form>
		<form action="index2.php" method="post" name="adminForm">
		<table class="adminlist">
				<tr valign="top">
					<th width="20">#</th>
					<th width="20">	<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" /></th>
					<th><?php echo _Profile_Username ; ?> </th>
					<th colspan="2" width="5%"><?php echo _E_ORDERING; ?></th>
					<th><?php echo _Profile_Name ; ?> </th>
					<th><?php echo _Profile_Email ; ?> </th>
				</tr>

<?php		

			$k = 0;
			for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];
				$k = 1 - $k;

				$link 		= 'index2.php?option=com_congregation&rub=profile&task=edit&hidemainmenu=1&username='. $row->username;

/*
				$task 	= $row->showBanner ? 'unpublish' : 'publish';
				$img 	= $row->showBanner ? 'publish_g.png' : 'publish_x.png';
				$alt 	= $row->showBanner ? 'Published' : 'Unpublished';
*/

				$checked 	= mosHTML::idBox( $i, $row->username);
?>
			<tr class="<?php echo "row$k"; ?>">
				<td  width="20">
				<?php echo $pageNav->rowNumber( $i ); ?>
				</td>
				<td  width="20">
				<?php echo $checked; ?>
				</td>
				<td><?php echo $row->lusername ; ?> </td>
				<td align="center">
				<?php echo $pageNav->orderUpIcon( $i ); ?>
				</td>
				<td align="center">
				<?php echo $pageNav->orderDownIcon( $i, $n ); ?>
				</td>
				<td align="center">
				<?php echo $row->lname . ' ' . $row->fname ; ?>
				</td>
				<td align="center">
				<?php echo $row->lemail; ?>
				</td>
			</tr>
			<?php
			}
?>
			</table>
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="rub" value="profile" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="c_id" value="<?php echo $c_id; ?>" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		<?php
		echo $pageNav->getListFooter(); 
		?>
		</form>

<?php		

	}

		function profile_edit(&$row, $option, &$lists) {
		global $Itemid, $params, $c_id, $mosConfig_live_site;

			?>
		<table class="adminheading">
		<tr>
			<th>
			<?php echo _Profile_Update_Heading; ?>
			</th>
		</tr>
		</table>
			
<form method=post action='' enctype='multipart/form-data'  name="adminForm">			
<?php

 	echo '<input type="hidden" name="rub" value="profile" />';
 	echo '<input type="hidden" name="task" value="save" />';
 	echo '<input type="hidden" name="c_id" value="$c_id" />';
 	echo '<input type="hidden" name="option" value="com_congregation" />';

		echo "
		<script language=\"JavaScript\">
		<!-- 
		function PopupAlbum(titre, img) {
		w=open(\"\",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=yes'); 
		w.document.write(\"<HTML><HEAD><TITLE>\"+titre+\"</TITLE></HEAD>\");
		w.document.write(\"<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+55,document.images[0].height+130); window.focus();} else { setTimeout('check()',250) } }</\"+\"SCRIPT>\");
		w.document.write(\"<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>\");
		w.document.write(\"<table border=1 cellpadding=20px cellspacing=0><tr><td align=center>\");
		w.document.write(\"<IMG src='\"+img+\"' border=0>\");
		w.document.write(\"</td></tr><table>\");
		w.document.write(\"</BODY></HTML>\");
		w.focus();
		w.document.close();
		}
		-->
		</script>

<table class='adminform' align='left' border=0 cellspacing=3 cellpadding=5>
 <tr>
  <td valign='top'>
   		<b> ";
		echo _Profile_Username ;

		echo " : </b>
  </td>
  <td valign='top'>
	  <select name='username'><option />
	  ";
	  foreach($lists['users'] as $users) {
	  	$selected = ($users->username == $row->username) ? " selected " : "";
		echo  "<option value='" . $users->username . "' $selected >" . $users->username . "</option>";
	  }

		echo "
		</select>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Photo ;
		echo " : </b>
  </td>
  <td>
";
if($row->picfile) {
echo  "
  <a href=\"javascript:PopupAlbum('". $row->fname . " " . $row->lname. "', '" . $mosConfig_live_site . "/media/profiles/".$row->picfile. "')\" ><img src='" . $mosConfig_live_site . "/media/profiles/s". $row->picfile . "' border='0' width='100'></a><br />
<input type='checkbox' name='removepic' value='1'> Remove <br />
";
}

echo  "<br>
   <input type='file' size='30' name='imagefile' style='width: 300px'><br>
  </td>
 </tr>
	";

echo  "
<tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Password ;
		echo " : </b>

  </td>
  <td valign='top'>
   <a href='?rub=login/changepass'>
		<b> ";
		echo _Profile_Change_Pass ;
		echo " : </b>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Alt_Email ;
		echo " : </b>

  </td>
  <td valign='top'>
   <input type=text name='altemail' value='$row->altemail' style='width: 200px'>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Last_Name ;
		echo " : </b>

  </td>
  <td valign='top'>
   <input type=text name='lname' value='$row->lname' style='width: 200px'>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_First_Name ;
		echo " : </b>

  </td>
  <td valign='top'>
   <input type=text name='fname' value='$row->fname' style='width: 200px'>
  </td>
 </tr>
";
 

	$b_label[0] = _Profile_Birth;
	$b_label[1] = _Profile_Entry;
	$b_label[2] = _Profile_Novitiate;
	$b_label[3] = _Profile_Prof;
	$b_label[4] = _Profile_Final;
	$b_label[5] = _Profile_Ordination;
	$b_label[6] = _Profile_Death;

	$b_day[0] = substr($row->bdate, 8, 2);
	$b_month[0] = substr($row->bdate, 5, 2);
	$b_year[0] = substr($row->bdate, 0, 4);
	$b_place[0] = $row->bplace;

	$b_day[1] = substr($row->edate, 8, 2);
	$b_month[1] = substr($row->edate, 5, 2);
	$b_year[1] = substr($row->edate, 0, 4);
	$b_place[1] = $row->eplace;

	$b_day[2] = substr($row->ndate, 8, 2);
	$b_month[2] = substr($row->ndate, 5, 2);
	$b_year[2] = substr($row->ndate, 0, 4);
	$b_place[2] = $row->nplace;

	$b_day[3] = substr($row->vdate, 8, 2);
	$b_month[3] = substr($row->vdate, 5, 2);
	$b_year[3] = substr($row->vdate, 0, 4);
	$b_place[3] = $row->vplace;

	$b_day[4] = substr($row->fdate, 8, 2);
	$b_month[4] = substr($row->fdate, 5, 2);
	$b_year[4] = substr($row->fdate, 0, 4);
	$b_place[4] = $row->fplace;

	$b_day[5] = substr($row->odate, 8, 2);
	$b_month[5] = substr($row->odate, 5, 2);
	$b_year[5] = substr($row->odate, 0, 4);
	$b_place[5] = $row->oplace;

	$b_day[6] = substr($row->ddate, 8, 2);
	$b_month[6] = substr($row->ddate, 5, 2);
	$b_year[6] = substr($row->ddate, 0, 4);
	$b_place[6] = $row->dplace;

for($m=0; $m<=6; $m++) {
 echo  "
 <tr>
  <td valign='top'>
   <b>$b_label[$m] : </b>
  </td>
  <td valign='top'>

<SELECT name='b_day[]'>
<OPTION selected>$b_day[$m]<OPTION>1 <OPTION>2 <OPTION>3 <OPTION>4 
<OPTION>5 <OPTION>6 <OPTION>7 <OPTION>8 <OPTION>9 
<OPTION>10
<OPTION>11 <OPTION>12 <OPTION>13 <OPTION>14 
<OPTION>15 <OPTION>16 <OPTION>17 <OPTION>18 
<OPTION>19 <OPTION>20 <OPTION>21
<OPTION>22 <OPTION>23 <OPTION>24 <OPTION>24 
<OPTION>25 <OPTION>26 <OPTION>27 <OPTION>28 
<OPTION>29 <OPTION>30 <OPTION>31
</SELECT>
<select name='b_month[]'>
<option value='$b_month[$m]' selected>$b_month[$m]</option>
";

for ($i=1; $i<=12; $i++) {
	echo  "<option value='$i'>$i</option>";
}

echo  "
</select>
<select name='b_year[]'>
<option selected>$b_year[$m]</option>";

$thisyear = date("Y");

for ($j = $thisyear - 200 ;$j <= $thisyear ; $j++) {
	echo  "<option value='$j'>$j</option>\n";
}
echo  "
</select> dd/mm/yyyy
  </td>
 </tr>
<tr>
  <td valign='top'><b>";
echo _Profile_Place . " " . $b_label[$m] . ": </b>
  </td>
  <td valign='top'>
   <input type=text name='b_place[]' value='$b_place[$m]' style='width: 200px'>
  </td>
 </tr>
";

}


echo  "
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Status ;
		echo " : </b>

  </td>
  <td valign='top'>
   <select name='status'><option value=0></option>
 ";
	  foreach($lists['status'] as $status) {
	  	$selected = ($status->id == $row->status) ? " selected " : "";
		echo  "<option value='" . $status->id . "' $selected >" . $status->text . "</option>";
	  }

echo  "
   </select>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Country ;
		echo " : </b>

  </td>
  <td valign='top'>
<select name='nationality'>
<option selected>$row->nationality<OPTION>Afghanistan<OPTION>Albania<OPTION>Algeria<OPTION>American Samoa<OPTION>Andorra<OPTION>Angola<OPTION>Anguilla<OPTION>Antarctica<OPTION>Antigua and arbuda<OPTION>Argentina<OPTION>Armenia<OPTION>Aruba<OPTION>Australia<OPTION>Austria<OPTION>Azerbaijan<OPTION>Bahamas<OPTION>Bahrain<OPTION>Bangladesh<OPTION>Barbados<OPTION>Belarus<OPTION>Belgium<OPTION>Belize<OPTION>Benin<OPTION>Bermuda<OPTION>Bhutan<OPTION>Bolivia<OPTION>Bosnia and Herzegovina<OPTION>Botswana<OPTION>Bouvet Island<OPTION>Brazil<OPTION>British Indian Ocean Territory<OPTION>Brunei Darussalam<OPTION>Bulgaria<OPTION>Burkina Faso<OPTION>Burundi<OPTION>Cambodia<OPTION>Cameroon<OPTION>Canada<OPTION>Cape Verde<OPTION>Cayman Islands<OPTION>Central African Republic<OPTION>Chad<OPTION>Chile<OPTION>China<OPTION>Christmas Island<OPTION>Cocos Keeling Islands<OPTION>Colombia<OPTION>Comoros<OPTION>Congo<OPTION>Cook Islands<OPTION>Costa Rica<OPTION>Ivory Coast<OPTION>Croatia<OPTION>Cuba<OPTION>Cyprus<OPTION>Czech Republic<OPTION>Denmark<OPTION>Djibouti<OPTION>Dominican Republic<OPTION>Dominica<OPTION>East Timor<OPTION>Ecuador<OPTION>Egypt<OPTION>El Salvador<OPTION>Equatorial Guinea<OPTION>Eritrea<OPTION>Estonia<OPTION>Ethiopia<OPTION>Falkland Islands<OPTION>Faroe Islands<OPTION>Fiji<OPTION>Finland<OPTION>France<OPTION>French Guiana<OPTION>French Polynesia<OPTION>French Southern Territories<OPTION>Gabon<OPTION>Gambia<OPTION>Georgia<OPTION>Germany<OPTION>Ghana<OPTION>Gibraltar<OPTION>Greece<OPTION>Greenland<OPTION>Grenada<OPTION>Guadeloupe<OPTION>Guam<OPTION>Guatemala<OPTION>Guinea-Bissau<OPTION>Guinea<OPTION>Guyana<OPTION>Haiti<OPTION>Heard and McDonald Islands<OPTION>Honduras<OPTION>Hong Kong<OPTION>Hungary<OPTION>Iceland<OPTION>India<OPTION>Indonesia<OPTION>Iran<OPTION>Iraq<OPTION>Ireland<OPTION>Israel<OPTION>Italy<OPTION>Jamaica<OPTION>Japan<OPTION>Jordan<OPTION>Kazakhstan<OPTION>Kenya<OPTION>Kiribati<OPTION>North Korea<OPTION>South Korea<OPTION>Kuwait<OPTION>Kyrgyzstan<OPTION>Laos<OPTION>Latvia<OPTION>Lebanon<OPTION>Lesotho<OPTION>Liberia<OPTION>Libya<OPTION>Liechtenstein<OPTION>Lithuania<OPTION>Luxembourg<OPTION>Macau<OPTION>Macedonia<OPTION>Madagascar<OPTION>Malawi<OPTION>Malaysia<OPTION>Maldives<OPTION>Mali<OPTION>Malta<OPTION>Marshall slands<OPTION>Martinique<OPTION>Mauritania<OPTION>Mauritius<OPTION>Mayotte<OPTION>Mexico<OPTION>Micronesia<OPTION>Moldova<OPTION>Monaco<OPTION>Mongolia<OPTION>Montserrat<OPTION>Morocco<OPTION>Mozambique<OPTION>Myanmar<OPTION>Namibia<OPTION>Nauru<OPTION>Nepal<OPTION>Netherlands Antilles<OPTION>Netherlands<OPTION>New Caledonia<OPTION>New Zealand<OPTION>Nicaragua<OPTION>Nigeria<OPTION>Niger<OPTION>Niue<OPTION>Norfolk Island<OPTION>Northern Mariana slands<OPTION>Norway<OPTION>Oman<OPTION>Pakistan<OPTION>Palau<OPTION>Panama<OPTION>Papua New Guinea<OPTION>Paraguay<OPTION>Peru<OPTION>Philippines<OPTION>Pitcairn<OPTION>Poland<OPTION>Portugal<OPTION>Puerto Rico<OPTION>Qatar<OPTION>Reunion<OPTION>Romania<OPTION>Russian Federation<OPTION>Rwanda<OPTION>S Georgia and S Sandwich Isles<OPTION>Saint Kitts and Nevis<OPTION>Saint Lucia<OPTION>Saint Vincent and The Grenadines<OPTION>Samoa<OPTION>San Marino<OPTION>Sao Tome and Principe<OPTION>Saudi Arabia<OPTION>Senegal<OPTION>Seychelles<OPTION>Sierra Leone<OPTION>Singapore<OPTION>Slovak Republic<OPTION>Slovenia<OPTION>Solomon Islands<OPTION>Somalia<OPTION>South Africa<OPTION>Spain<OPTION>Sri Lanka<OPTION>St. Helena<OPTION>St. Pierre and Miquelon<OPTION>Sudan<OPTION>Suriname<OPTION>Svalbard and Jan Mayen Islands<OPTION>Swaziland<OPTION>Sweden<OPTION>Switzerland<OPTION>Syria<OPTION>Taiwan<OPTION>Tajikistan<OPTION>Tanzania<OPTION>Thailand<OPTION>Togo<OPTION>Tokelau<OPTION>Tonga<OPTION>Trinidad and Tobago<OPTION>Tunisia<OPTION>Turkey<OPTION>Turkmenistan<OPTION>Turks and Caicos Islands<OPTION>Tuvalu<OPTION>US Minor Outlying Islands<OPTION>Uganda<OPTION>Ukraine<OPTION>United Arab Emirates<OPTION>United Kingdom<OPTION>United States<OPTION>Uruguay<OPTION>Uzbekistan<OPTION>Vanuatu<OPTION>Vatican City State<OPTION>Venezuela<OPTION>Viet Nam<OPTION>British Virgin Islands<OPTION>US Virgin Islands<OPTION>Wallis and Futuna Islands<OPTION>Western Sahara<OPTION>Yemen<OPTION>Yugoslavia<OPTION>Zaire<OPTION>Zambia<OPTION>Zimbabwe</select>

	  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Lang ;
		echo " : </b>

  </td>
  <td valign='top'>
          <select name=\"language\" ><option />
";
	  foreach($lists['language'] as $language) {
	  	$selected = ($language->iso == $row->language) ? " selected " : "";
		echo  "<option value='" . $language->iso . "' $selected >" . $language->name . "</option>";
	  }
	echo  "
          </select>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Community ;
		echo " : </b>

  </td>
  <td valign='top'>
     <select class='input_gen' name='c_id' style='width:200'>
	  <option />
  ";
    foreach($lists['casa'] as $casa) {
      $selected = ($c_id ? $casa->c_id == $c_id : ($casa->c_id == $row->c_id ) ? " selected ": "");
      echo  "<option value='" . $casa->c_id . "' $selected>". $casa->c_city . " - ". $casa->c_name . "</option>\n";
    }

echo  "
   </select>
  </td>
 </tr>
 <tr>
  <td valign='top'>
		<b> ";
		echo _Profile_Cell ;
		echo " : </b>

  </td>
  <td valign='top'>
   <input type=text name='cell' value='$row->cell' style='width: 200px'>
  </td>
 </tr>
 <tr>
  <td valign='top'>
   <b>";
  echo _Profile_Skype;
  echo " </b>
  </td>
  <td valign='top'>
   <input type=text name='skype' value='$row->skype' style='width: 200px'>
  </td>
 </tr>
</table>
</form>
";

	}
}

?>